library(dplyr)
library(plotly)
aegypti <- read.csv("aegypti_albopictus.csv", header = TRUE, sep = ",")
# filtering
yr04 <- aegypti %>%
  select(VECTOR, Y, X, COUNTRY, YEAR) %>%
  filter(YEAR == 2004)

yr13 <- aegypti %>%
  select(VECTOR, Y, X, COUNTRY, YEAR) %>%
  filter(YEAR == 2013)
yr04_p <- yr04 %>%
 plot_mapbox(x= ~X, y =~Y, split =~VECTOR, mode = "scattermapbox", hoverinfo = 'name') %>%
  layout(title = 'Scatter',
         font = list(color='white'),
         plot_bgcolor = '#191A1A', paper_bgcolor = '#191A1A',
         mapbox = list(style = 'light'),
         legend = list(orientation = 'h',
                       font = list(size = 8)),
         margin = list(l = 25, r = 25,
                       b = 25, t = 25,
                       pad = 2))

yr04_p
yr13_p <- yr13 %>%
 plot_mapbox(x= ~X, y =~Y, split =~VECTOR, mode = "scattermapbox", hoverinfo = 'name') %>%
  layout(title = 'Scatter',
         font = list(color='white'),
         plot_bgcolor = '#191A1A', paper_bgcolor = '#191A1A',
         mapbox = list(style = 'light'),
         legend = list(orientation = 'h',
                       font = list(size = 8)),
         margin = list(l = 25, r = 25,
                       b = 25, t = 25,
                       pad = 2))

yr13_p
Z <- aegypti %>%
  group_by(COUNTRY) %>%
  mutate(z = n())
# WORLD MAP
g <- list(
  projection = list(type = 'Mercator')
)
p <- plot_geo(Z) %>%
  add_trace(
    z = ~z, x =~X, y =~Y, color = ~z, colors = 'Blues',
    text = ~COUNTRY
  ) %>%
    layout(
    geo = g
  )

p
## Warning: 'choropleth' objects don't have these attributes: 'x', 'y'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'locations', 'locationmode', 'z', 'text', 'marker', 'selected', 'unselected', 'zauto', 'zmin', 'zmax', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'geo', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'locationssrc', 'zsrc', 'textsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'